<?php

class Application_Form_Login extends Zend_Form {

    private $_translate;

    public function init() {
        $this->_translate = Zend_Registry::get('Zend_Translate');
        #db
        $optionsDb = new Application_Model_Options();
        $userType = $optionsDb->getByName("userType");

        #
        $this->setMethod("post");

        #user email
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel($this->_translate->_('enter_email').':')
                ->setAttribs(array('class' => 'span12', 'placeholder' => $this->_translate->_('enter_email').':'))
                ->setRequired()
                ->addFilter("StringTrim")
                ->addValidator("EmailAddress");

        #user type
        $type = new Zend_Form_Element_Select('type');
        $type->setLabel($this->_translate->_('user_type').':')
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'));
        $index = 1;
        foreach ($userType['details'] as $usertype) {
            $type->addMultiOption($index, $this->_translate->_($usertype));
            $index++;
        }

        #password
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel($this->_translate->_('password').':')
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'placeholder' => $this->_translate->_('password')));


        #submit
        $submit = new Zend_Form_Element_Submit("submit");
        $submit->setLabel("Create New User")
                ->setAttribs(array('class' => 'btn btn-success btn-large'));

        #
        $this->addElements(array($type, $email, $password, $submit));
    }

}

